import BasicLayout from '../layouts/BasicLayout';
// import BlankLayout from '../layouts/BlankLayout';

import Home from '../routes/Home';
import Approver from '../routes/Approver/TableList';
// import Project from '../routes/Project/ProjectList';
// import ProjectCreate from '../routes/Project/ProjectCreate';
import TeamUser from '../routes/Team/TeamUserList';
// import TeamTasks from '../routes/Team/TeamTasks';
import Statistics from '../routes/Statistics/Statistics';
import TeamStatistics from '../routes/Statistics/TeamStatistics';

import Writer from '../routes/Writer/TableList';
import TaskCreeation from '../routes/Writer/TaskCreeation';

// import TaskSquare from '../routes/TaskSquare/ProjectList';
// import SubmissionList from '../routes/TaskSquare/SubmissionList';
import Invitation from '../routes/Invitation/InvitationList';
import Material from '../routes/Material';

import * as Tool from '../routes/Tool/index';

// import Success from '../routes/Result/Success';
// import Error from '../routes/Result/Error';

import Setting from '../routes/Team/Setting'
// import Setting from '../routes/User/UserInfo';

import { RIGHT } from '../constants';

const home = {
  name: '首页',
  path: 'home',
  icon: 'home',
  children: [],
  component: Home,
};
// const square = {
//   name: '广场',
//   path: 'square',
//   icon: 'appstore-o',
//   children: [{
//     name: '赏金任务',
//     path: 'task',
//     component: TaskSquare,
//   }, {
//     name: '投稿',
//     path: 'submission',
//     component: SubmissionList,
//   }],
// };

const creation = {
  name: '创作',
  path: 'creation',
  icon: 'edit',
  children: [{
    name: '全部作品',
    path: 'writer-list',
    component: Writer,
  }, {
    name: '新建作品',
    path: 'writer-create',
    component: TaskCreeation,
  }, {
    name: '素材中心',
    path: 'album',
    component: Material,
  }, {
    name: '淘宝热点',
    path: 'https://aidea.taobao.com/',
    target: '_blank',
  }],
};

// const project = {
//   name: '活动',
//   path: 'project',
//   icon: 'file',
//   children: [{
//     name: '活动列表',
//     path: 'list',
//     component: Project,
//   }, {
//     name: '新建活动',
//     path: 'create',
//     component: ProjectCreate,
//   }],
// };

const approve = {
  name: '待办',
  path: 'approve',
  icon: 'solution',
  children: [],
  component: Approver,
};

const team = {
  name: '设置',
  path: 'team',
  icon: 'team',
  children: [{
  //   name: '全部任务',
  //   path: 'teamTasks-list',
  //   component: TeamTasks,
  // }, {
    name: '角色权限',
    path: 'teamUser-list',
    component: TeamUser,
  }, {
    name: '邀请码',
    path: 'invitation-list',
    component: Invitation,
  }, {
    name: '个人中心',
    path: 'personal-setting',
    component: Setting,
  }],
};

const darenStatistics = {
  name: '我的发布',
  path: 'daren',
  component: Statistics,
};

const teamStatistics = {
  name: '团队发布',
  path: 'team',
  component: TeamStatistics,
};

const statistics = {
  name: '统计',
  path: 'statistics',
  icon: 'area-chart',
  children: [],
};

const tool = {
  name: '工具',
  path: 'tool',
  icon: 'tool',
  children: [{
    name: '店铺商品检测',
    path: 'pools',
    component: Tool.ShopPool,
  }],
};

const data = [{
  component: BasicLayout,
  layout: 'BasicLayout',
  name: '首页', // for breadcrumb
  path: '',
  children: [],
}];

export function getNavData(user) {
  const menuItems = [home];
  if (user.rights) {
    if (user.rights.indexOf(RIGHT.writer) >= 0) {
      menuItems.push(creation);
    }
    if (user.rights.indexOf(RIGHT.approver) >= 0 || user.rights.indexOf(RIGHT.daren) >= 0) {
      menuItems.push(approve);
    }
    if (user.rights.indexOf(RIGHT.teamAdmin) >= 0) {
      menuItems.push(team);
    }
    // if (user.rights.indexOf(RIGHT.projectCreator) >= 0 || user.rights.indexOf(RIGHT.projectAdmin) >= 0) {
    //   menuItems.push(project);
    // }
    if (user.rights.indexOf(RIGHT.daren) >= 0 || user.rights.indexOf(RIGHT.teamAdmin) >= 0) {
      statistics.children = [];
      if (user.rights.indexOf(RIGHT.daren) >= 0) {
        statistics.children.push(darenStatistics);
      }
      if (user.rights.indexOf(RIGHT.teamAdmin) >= 0) {
        statistics.children.push(teamStatistics);
      }
      menuItems.push(statistics);
    }
  } else {
    menuItems.push(creation, approve, team, statistics);
  }
  menuItems.push(tool);
  data[0].children = menuItems;
  return data;
}

export default data;
